<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>访问器</title>
</head>
<body>
	
	<script>
		var book = {
			_year: 2004,
			edition: 1
		};

		Object.defineProperty(book,'year', {
			get:function() {
				return this._year;
			},
			set: function(newValue) {
				if (newValue > 2004) {
					this._year = newValue;
					this.edition += newValue - 2004;
				}
			}
		});

		book.year = 2005;
		alert(book.edition);

	</script>
</body>
</html>